<template>
  <div class="container">
    <el-form :model="form" label-width="120px">
      <el-row :gutter="20">
        <el-form-item label="选择商品" required>
          <el-select v-model="form.skuId" placeholder="请选择商品">
            <el-option
              v-for="sku in skus"
              :key="sku.id"
              :label="sku.spuName"
              :value="sku.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-row>
      <el-row :gutter="20">
        <el-form-item label="开始时间" required>
          <el-date-picker
            v-model="form.startTime"
            type="datetime"
            placeholder="选择开始时间"
          >
          </el-date-picker>
        </el-form-item>
      </el-row>

      <el-row :gutter="20">
        <el-form-item label="结束时间" required>
          <el-date-picker
            v-model="form.endTime"
            type="datetime"
            placeholder="选择结束时间"
          >
          </el-date-picker>
        </el-form-item>
      </el-row>

      <el-row :gutter="20">
        <el-form-item label="优惠积分价格" required>
            <el-input v-model="form.integral" placeholder="请输入积分"></el-input>
        </el-form-item>
      </el-row>

      <el-row :gutter="20">
        <el-form-item label="商品数量" required>
            <el-input v-model="form.num" placeholder="请输入数量"></el-input>
        </el-form-item>
      </el-row>

      <el-form-item>
        <el-button type="primary" @click="submitForm">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
    
    <script>
export default {
  data() {
    return {
      imageUrl: "",
      form: {

      },
      skus:[],
    };
  },
  methods: {
    submitForm(){
      this.$axios.post("/api/zgyd-jifen/newKill", this.form).then(res => {
        if (res.data.code === 200) {
            alert(res.data.data)
        }
      });
    },
    querySkus() {
      this.$axios.post("/api/zgyd-jifen/querySpus").then((res) => {
        if (res.data.code === 200) {
          this.skus = res.data.data;
        }
      });
    },
  },
  created() {
    this.querySkus();
  },
};
</script>
    
  <style scoped>
.el-row {
  margin-bottom: 20px;
}
.el-row:last-child {
  margin-bottom: 0;
}
.avatar {
  width: 120px; /* 调整为你需要的宽度 */
  height: 120px; /* 调整为你需要的高度 */
  object-fit: cover; /* 这条语句会使图片以 "cover" 模式显示，保持图片的本身比例长宽比，裁剪超出部分 */
}
.el-input,
.el-select,
.el-cascader {
  width: 100% !important;
}
.el-button {
  border-radius: 20px;
  text-align: center; /* 文字居中  */
  border: none;
  color: white; /* 文字颜色白色  */
  cursor: pointer;
  display: inline-block;
  background: linear-gradient(
    to right,
    rgb(176, 119, 218),
    rgb(129, 214, 238)
  ); /* 渐变效果更换为浅紫色到浅蓝色 */
  transition-property: background-color, transform; /* 添加过渡属性 */
  transition-duration: 0.3s; /* 过渡持续时间 */
}
.el-button:hover {
  transform: scale(1.1); /* 按钮放大效果  */
  transition: transform 0.3s ease-in-out;
}
/* 图片边框动效 */
.avatar {
  border: 2px solid #ffffff;
  transition: border 0.5s ease-in-out;
}

.avatar:hover {
  border: 2px solid #12cbc4; /*鼠标悬停图片边框会变色*/
}

/* 输入框获取焦点时边框颜色变化 */
.el-input__inner:focus {
  border-color: #12cbc4;
}

/* 下拉框获取焦点时边框颜色变化 */
.el-select .el-input.is-focus .el-input__inner {
  border-color: #12cbc4;
}

/* 级联选择器获取焦点时边框颜色变化 */
.el-cascader .el-input.is-focus .el-input__inner {
  border-color: #12cbc4;
}
.container {
  position: relative;
  margin: 1rem;
  padding: 2.5rem;
  background: white;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  overflow: hidden;
  background: linear-gradient(60deg, #c4dcda 0%, #96e4e1 100%);
}
.form-required:before {
  content: "*";
  color: red;
}
</style>